
Product
Rubygems Ecosystem Support Now Generally Available
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
core-types-ts
Advanced tools
This package provides conversion functions between core-types
and TypeScript.
You probably don't want to use this package directly, but rather typeconv
which uses this package to convert between TypeScript, JSON Schema and GraphQL.
Other conversion packages:
core-types-json-schema
core-types-graphql
core-types-suretype
(which is also using this package)There are two conversion functions, convertCoreTypesToTypeScript
and convertTypeScriptToCoreTypes
, both returning a wrapped value, of the type ConversionResult
.
import { convertCoreTypesToTypeScript } from 'core-types-ts'
let doc; // This core-types document comes from somewhere
const { data: tsSourceCode } = convertCoreTypesToTypeScript( doc );
You can provide options as a second argument fn the type:
interface ToTsOptions
{
warn?: WarnFunction;
filename?: string;
sourceFilename?: string;
useUnknown?: boolean;
declaration?: boolean;
userPackage?: string;
userPackageUrl?: string;
noDisableLintHeader?: boolean;
noDescriptiveHeader?: boolean;
unsupported?: 'ignore' | 'warn' | 'error';
}
These options are all optional.
warn
: A function callback to be used for warnings, defaults to console.warn
.filename
The filename to be written to.sourceFilename
: The name of the source file from which the core-types comes.useUnknown
: Use unknown
rather than any
for any-types.declaration
: Write a declaration file, where e.g. "export interface" becomes "export declare interface".userPackage
: The name of the package using this package.userPackageUrl
: The url to the package using this package.noDisableLintHeader
: Prevent writing the "disable linting" comment.noDescriptiveHeader
: Do no write a top-level descriptive comment about the auto-generated fileunsupported
: What to do when detecting an unsupported type
ignore
: Ignore (skip) typewarn
: Ignore type, but warn (default)error
: Throw an errorThe warn
function is of type WarnFunction
from core-types
, meaning it takes a message as string, and an optional second argument of type CoreTypesErrorMeta
, also from core-types
.
import { convertTypeScriptToCoreTypes } from 'core-types-ts'
let sourceCode; // This source code comes from somewhere
const { data: doc } = convertTypeScriptToCoreTypes( sourceCode );
An optional second argument can be provided on the form
interface FromTsOptions
{
warn?: WarnFunction;
nonExported?: 'fail' | 'ignore' | 'include' | 'inline' | 'include-if-referenced';
unsupported?: 'ignore' | 'warn' | 'error';
}
warn
: The same warn function as in CoreTypesToGraphqlOptionsnonExported
: How to handle references to non-exported types
fail
: Fail conversion with an Errorignore
: Don't include non-exported types, but allow references to theminclude
: Include non-exported typesinline
: Don't include non-exported types, inline them if necessary.include-if-referenced
: Include non-exported types only if they are referencedunsupported
: What to do when detecting an unsupported type
ignore
: Ignore (skip) type (default)warn
: Ignore type, but warnerror
: Throw an errorFAQs
core-types ⬌ TypeScript interface conversion
The npm package core-types-ts receives a total of 16,070 weekly downloads. As such, core-types-ts popularity was classified as popular.
We found that core-types-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
Research
The Socket Research Team investigates a malicious npm package that appears to be an Advcash integration but triggers a reverse shell during payment success, targeting servers handling transactions.
Security Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.